package com.dede.dreamserver

import android.service.dreams.DreamService
import android.util.Log
import android.widget.Toast

/**
 * @author hsh
 * @date 2018/1/29 17:17.
 * @doc
 */
class TestDreamServer : DreamService() {

    private val TAG = "TestDreamServer"

    init {
        val method = this.javaClass.getMethod("setDebug", Boolean::class.java)
        method.isAccessible = true
        method.invoke(this, true)
    }

    override fun onAttachedToWindow() {
        super.onAttachedToWindow()
        // Exit dream upon user touch
        isInteractive = false
        // Hide system UI
        isFullscreen = true
        // Set the dream layout
        setContentView(R.layout.layout_dream)
    }

    override fun onDreamingStarted() {
        super.onDreamingStarted()
        Log.i(TAG, "onDreamingStarted: ")
        Toast.makeText(this, "start", Toast.LENGTH_SHORT).show()
    }

    override fun onDreamingStopped() {
        super.onDreamingStopped()
        Log.i(TAG, "onDreamingStopped: ")
        Toast.makeText(this, "stop", Toast.LENGTH_SHORT).show()
    }
}